home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / PInterfaces / SoundInput.p < prev    next >
Encoding:
Text File  |  1995-07-07  |  10.1 KB  |  286 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SoundInput.p
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.1 in “MPW Latest” on ETO #19
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT SoundInput;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __SOUNDINPUT__}
  30. {$SETC __SOUNDINPUT__ := 1}
  31.  
  32. {$I+}
  33. {$SETC SoundInputIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __APPLEEVENTS__}
  43. {$I AppleEvents.p}
  44. {$ENDC}
  45. {    Errors.p                                                    }
  46. {    Memory.p                                                    }
  47. {        MixedMode.p                                                }
  48. {    OSUtils.p                                                    }
  49. {    Events.p                                                    }
  50. {        Quickdraw.p                                                }
  51. {            QuickdrawText.p                                        }
  52. {    EPPC.p                                                        }
  53. {        AppleTalk.p                                                }
  54. {        Files.p                                                    }
  55. {            Finder.p                                            }
  56. {        PPCToolbox.p                                            }
  57. {        Processes.p                                                }
  58. {    Notification.p                                                }
  59.  
  60. {$IFC UNDEFINED __WINDOWS__}
  61. {$I Windows.p}
  62. {$ENDC}
  63. {    Controls.p                                                    }
  64. {        Menus.p                                                    }
  65.  
  66. {$IFC UNDEFINED __DIALOGS__}
  67. {$I Dialogs.p}
  68. {$ENDC}
  69. {    TextEdit.p                                                    }
  70.  
  71. {$IFC UNDEFINED __FILES__}
  72. {$I Files.p}
  73. {$ENDC}
  74.  
  75. {$IFC UNDEFINED __SOUND__}
  76. {$I Sound.p}
  77. {$ENDC}
  78. {    Components.p                                                }
  79.  
  80. {$PUSH}
  81. {$ALIGN MAC68K}
  82. {$LibExport+}
  83.  
  84. CONST
  85.     siDeviceIsConnected            = 1;                            {input device is connected and ready for input}
  86.     siDeviceNotConnected        = 0;                            {input device is not connected}
  87.     siDontKnowIfConnected        = -1;                            {can't tell if input device is connected}
  88.     siReadPermission            = 0;                            {permission passed to SPBOpenDevice}
  89.     siWritePermission            = 1;                            {permission passed to SPBOpenDevice}
  90.  
  91. {Info Selectors for Sound Input Drivers}
  92.     siActiveChannels            = 'chac';                        {active channels}
  93.     siActiveLevels                = 'lmac';                        {active meter levels}
  94.     siAGCOnOff                    = 'agc ';                        {automatic gain control state}
  95.     siAsync                        = 'asyn';                        {asynchronous capability}
  96.     siChannelAvailable            = 'chav';                        {number of channels available}
  97.     siCompressionAvailable        = 'cmav';                        {compression types available}
  98.     siCompressionFactor            = 'cmfa';                        {current compression factor}
  99.     siCompressionHeader            = 'cmhd';                        {return compression header}
  100.     siCompressionNames            = 'cnam';                        {compression type names available}
  101.     siCompressionType            = 'comp';                        {current compression type}
  102.     siContinuous                = 'cont';                        {continous recording}
  103.     siDeviceBufferInfo            = 'dbin';                        {size of interrupt buffer}
  104.     siDeviceConnected            = 'dcon';                        {input device connection status}
  105.     siDeviceIcon                = 'icon';                        {input device icon}
  106.     siDeviceName                = 'name';                        {input device name}
  107.     siHardwareBusy                = 'hwbs';                        {sound hardware is in use}
  108.     siInputGain                    = 'gain';                        {input gain}
  109.     siInputSource                = 'sour';                        {input source selector}
  110.     siInputSourceNames            = 'snam';                        {input source names}
  111.     siLevelMeterOnOff            = 'lmet';                        {level meter state}
  112.     siModemGain                    = 'mgai';                        {modem input gain}
  113.     siNumberChannels            = 'chan';                        {current number of channels}
  114.     siOptionsDialog                = 'optd';                        {display options dialog}
  115.     siPlayThruOnOff                = 'plth';                        {playthrough state}
  116.     siRecordingQuality            = 'qual';                        {recording quality}
  117.     siSampleRate                = 'srat';                        {current sample rate}
  118.     siSampleRateAvailable        = 'srav';                        {sample rates available}
  119.     siSampleSize                = 'ssiz';                        {current sample size}
  120.     siSampleSizeAvailable        = 'ssav';                        {sample sizes available}
  121.     siSetupCDAudio                = 'sucd';                        {setup sound hardware for CD audio}
  122.     siSetupModemAudio            = 'sumd';                        {setup sound hardware for modem audio}
  123.     siStereoInputGain            = 'sgai';                        {stereo input gain}
  124.     siTwosComplementOnOff        = 'twos';                        {two's complement state}
  125.     siVoxRecordInfo                = 'voxr';                        {VOX record parameters}
  126.     siVoxStopInfo                = 'voxs';                        {VOX stop parameters}
  127.     siCloseDriver                = 'clos';                        {reserved for internal use only}
  128.     siInitializeDriver            = 'init';                        {reserved for internal use only}
  129.     siPauseRecording            = 'paus';                        {reserved for internal use only}
  130.     siUserInterruptProc            = 'user';                        {reserved for internal use only}
  131. {Qualities}
  132.     siCDQuality                    = 'cd  ';                        {44.1kHz, stereo, 16 bit}
  133.     siBestQuality                = 'best';                        {22kHz, mono, 8 bit}
  134.     siBetterQuality                = 'betr';                        {22kHz, mono, MACE 3:1}
  135.     siGoodQuality                = 'good';
  136.  
  137.     
  138. TYPE
  139.     SPBPtr = ^SPB;
  140.  
  141. {user procedures called by sound input routines}
  142.     {
  143.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  144.         be written in or called from a high-level language without the help of
  145.         mixed mode or assembly glue.
  146.  
  147.         In:
  148.          => inParamPtr      A0.L
  149.          => dataBuffer      A1.L
  150.          => peakAmplitude    D0.W
  151.          => sampleSize      D1.L
  152.     }
  153.     SIInterruptProcPtr = Register68kProcPtr;  { register PROCEDURE SIInterrupt(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT); }
  154.     SICompletionProcPtr = ProcPtr;  { PROCEDURE SICompletion(inParamPtr: SPBPtr); }
  155.     SIInterruptUPP = UniversalProcPtr;
  156.     SICompletionUPP = UniversalProcPtr;
  157.  
  158.     SPB = RECORD
  159.         inRefNum:                LONGINT;                                {reference number of sound input device}
  160.         count:                    LONGINT;                                {number of bytes to record}
  161.         milliseconds:            LONGINT;                                {number of milliseconds to record}
  162.         bufferLength:            LONGINT;                                {length of buffer in bytes}
  163.         bufferPtr:                Ptr;                                    {buffer to store sound data in}
  164.         completionRoutine:        SICompletionUPP;                        {completion routine}
  165.         interruptRoutine:        SIInterruptUPP;                            {interrupt routine}
  166.         userLong:                LONGINT;                                {user-defined field}
  167.         error:                    OSErr;                                    {error}
  168.         unused1:                LONGINT;                                {reserved - must be zero}
  169.     END;
  170.  
  171.  
  172. FUNCTION SPBVersion: NumVersion;
  173.     {$IFC NOT GENERATINGCFM}
  174.     INLINE $203C, $0000, $0014, $A800;
  175.     {$ENDC}
  176. FUNCTION SndRecord(filterProc: ModalFilterUPP; corner: Point; quality: OSType; VAR sndHandle: SndListHandle): OSErr;
  177.     {$IFC NOT GENERATINGCFM}
  178.     INLINE $203C, $0804, $0014, $A800;
  179.     {$ENDC}
  180. FUNCTION SndRecordToFile(filterProc: ModalFilterUPP; corner: Point; quality: OSType; fRefNum: INTEGER): OSErr;
  181.     {$IFC NOT GENERATINGCFM}
  182.     INLINE $203C, $0708, $0014, $A800;
  183.     {$ENDC}
  184. FUNCTION SPBSignInDevice(deviceRefNum: INTEGER; deviceName: ConstStr255Param): OSErr;
  185.     {$IFC NOT GENERATINGCFM}
  186.     INLINE $203C, $030C, $0014, $A800;
  187.     {$ENDC}
  188. FUNCTION SPBSignOutDevice(deviceRefNum: INTEGER): OSErr;
  189.     {$IFC NOT GENERATINGCFM}
  190.     INLINE $203C, $0110, $0014, $A800;
  191.     {$ENDC}
  192. FUNCTION SPBGetIndexedDevice(count: INTEGER; VAR deviceName: Str255; VAR deviceIconHandle: Handle): OSErr;
  193.     {$IFC NOT GENERATINGCFM}
  194.     INLINE $203C, $0514, $0014, $A800;
  195.     {$ENDC}
  196. FUNCTION SPBOpenDevice(deviceName: ConstStr255Param; permission: INTEGER; VAR inRefNum: LONGINT): OSErr;
  197.     {$IFC NOT GENERATINGCFM}
  198.     INLINE $203C, $0518, $0014, $A800;
  199.     {$ENDC}
  200. FUNCTION SPBCloseDevice(inRefNum: LONGINT): OSErr;
  201.     {$IFC NOT GENERATINGCFM}
  202.     INLINE $203C, $021C, $0014, $A800;
  203.     {$ENDC}
  204. FUNCTION SPBRecord(inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  205.     {$IFC NOT GENERATINGCFM}
  206.     INLINE $203C, $0320, $0014, $A800;
  207.     {$ENDC}
  208. FUNCTION SPBRecordToFile(fRefNum: INTEGER; inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  209.     {$IFC NOT GENERATINGCFM}
  210.     INLINE $203C, $0424, $0014, $A800;
  211.     {$ENDC}
  212. FUNCTION SPBPauseRecording(inRefNum: LONGINT): OSErr;
  213.     {$IFC NOT GENERATINGCFM}
  214.     INLINE $203C, $0228, $0014, $A800;
  215.     {$ENDC}
  216. FUNCTION SPBResumeRecording(inRefNum: LONGINT): OSErr;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $203C, $022C, $0014, $A800;
  219.     {$ENDC}
  220. FUNCTION SPBStopRecording(inRefNum: LONGINT): OSErr;
  221.     {$IFC NOT GENERATINGCFM}
  222.     INLINE $203C, $0230, $0014, $A800;
  223.     {$ENDC}
  224. FUNCTION SPBGetRecordingStatus(inRefNum: LONGINT; VAR recordingStatus: INTEGER; VAR meterLevel: INTEGER; VAR totalSamplesToRecord: LONGINT; VAR numberOfSamplesRecorded: LONGINT; VAR totalMsecsToRecord: LONGINT; VAR numberOfMsecsRecorded: LONGINT): OSErr;
  225.     {$IFC NOT GENERATINGCFM}
  226.     INLINE $203C, $0E34, $0014, $A800;
  227.     {$ENDC}
  228. FUNCTION SPBGetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  229.     {$IFC NOT GENERATINGCFM}
  230.     INLINE $203C, $0638, $0014, $A800;
  231.     {$ENDC}
  232. FUNCTION SPBSetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  233.     {$IFC NOT GENERATINGCFM}
  234.     INLINE $203C, $063C, $0014, $A800;
  235.     {$ENDC}
  236. FUNCTION SPBMillisecondsToBytes(inRefNum: LONGINT; VAR milliseconds: LONGINT): OSErr;
  237.     {$IFC NOT GENERATINGCFM}
  238.     INLINE $203C, $0440, $0014, $A800;
  239.     {$ENDC}
  240. FUNCTION SPBBytesToMilliseconds(inRefNum: LONGINT; VAR byteCount: LONGINT): OSErr;
  241.     {$IFC NOT GENERATINGCFM}
  242.     INLINE $203C, $0444, $0014, $A800;
  243.     {$ENDC}
  244. FUNCTION SetupSndHeader(sndHandle: SndListHandle; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; baseNote: INTEGER; numBytes: LONGINT; VAR headerLen: INTEGER): OSErr;
  245.     {$IFC NOT GENERATINGCFM}
  246.     INLINE $203C, $0D48, $0014, $A800;
  247.     {$ENDC}
  248. FUNCTION SetupAIFFHeader(fRefNum: INTEGER; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; numBytes: LONGINT; numFrames: LONGINT): OSErr;
  249.     {$IFC NOT GENERATINGCFM}
  250.     INLINE $203C, $0B4C, $0014, $A800;
  251.     {$ENDC}
  252. CONST
  253.     uppSIInterruptProcInfo = $1C579802; { Register PROCEDURE (4 bytes in A0, 4 bytes in A1, 2 bytes in D0, 4 bytes in D1); }
  254.     uppSICompletionProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  255.  
  256. FUNCTION NewSIInterruptProc(userRoutine: SIInterruptProcPtr): SIInterruptUPP;
  257.     {$IFC NOT GENERATINGCFM }
  258.     INLINE $2E9F;
  259.     {$ENDC}
  260.  
  261. FUNCTION NewSICompletionProc(userRoutine: SICompletionProcPtr): SICompletionUPP;
  262.     {$IFC NOT GENERATINGCFM }
  263.     INLINE $2E9F;
  264.     {$ENDC}
  265.  
  266. PROCEDURE CallSIInterruptProc(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT; userRoutine: SIInterruptUPP);
  267.     {$IFC NOT GENERATINGCFM}
  268.     {To be implemented:  Glue to move parameters into registers.}
  269.     {$ENDC}
  270.  
  271. PROCEDURE CallSICompletionProc(inParamPtr: SPBPtr; userRoutine: SICompletionUPP);
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $205F, $4E90;
  274.     {$ENDC}
  275.  
  276. {$ALIGN RESET}
  277. {$POP}
  278.  
  279. {$SETC UsingIncludes := SoundInputIncludes}
  280.  
  281. {$ENDC} {__SOUNDINPUT__}
  282.  
  283. {$IFC NOT UsingIncludes}
  284.  END.
  285. {$ENDC}
  286.